package com.xx.jicheng.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;
import org.springframework.web.servlet.mvc.LastModified;
import org.springframework.web.servlet.support.WebContentGenerator;

@Controller("/root.js")
public class RootController extends AbstractController implements LastModified {

	public RootController() {
		super();
		this.setCacheSeconds(Integer.MAX_VALUE);
		this.setSupportedMethods(WebContentGenerator.METHOD_GET);
	}

	@Override
	protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
			throws Exception {		
		System.out.println("enter...");
		String script = "var root='"+request.getContextPath()+"';";
		response.setContentType("text/javascript");
		response.getWriter().println(script );
		return null;
	}

	@Override
	public long getLastModified(HttpServletRequest request) {
		return 0;
	}

}
